import request from '@/router/axios';
import store from "@/store";

//公众号开始
//获取授权跳转路径
export function getAuthurl () {
    return request({
        url: '/cp/wx/authorization',
        method: 'get',
    })
}

// /获取公众号accessToken
export function getAccessToken (query) {
    return request({
        url: '/cp/wx/access',
        method: 'get',
        params: query
    })
}
//获取授权公众号列表
export function getAccessList (query) {
    return request({
        url: '/cp/wx/index',
        method: 'get',
        params: query
    })
}
//选择展示的公众号
export function getChangeAccessList (query) {
    return request({
        url: '/cp/wx/change',
        method: 'get',
        params: query
    })
}
//获取展示的公众号列表
export function getDisplayAccessList (query) {
    return request({
        url: '/cp/wx/status',
        method: 'get',
        params: query
    })
}
// 获取公众号素材列表
export function getDataList (query) {
    return request({
        url: '/cp/wx/page',
        method: 'get',
        params: query
    })
}
//查询当前公众号的素材
export function getMaterialList (query) {
    return request({
        url: '/cp/marketing-article/material',
        method: 'get',
        params: query
    })
}
//保存选中的文章素材
export function saveMaterial (obj) {
    return request({
        url: '/cp/marketing-article/post/material',
        method: 'post',
        data: obj
    })
}
//保存并发布选中的素材
export function savePublishMaterial (obj) {
    return request({
        url: '/cp/marketing-article/put/material',
        method: 'put',
        data: obj
    })
}
//公众号结束

//分类 开始

// 分类列表
export function getClassificationList () {
    return request({
        url: '/cp/marketing-classification/index',
        method: 'get',
    })
}
//分类 新增 post 编辑 put
export function newAndEditClassification (obj, method) {
    return request({
        url: '/cp/marketing-classification',
        method: method,
        data: obj
    })
}
//删除
export function deleteClassification (id) {
    return request({
        url: `/cp/marketing-classification/${id}`,
        method: 'delete',
    })
}
//分类 结束

//  推荐开始

//营销素材-推荐列表

export function getRecommedData (query) {
    return request({
        url: '/cp/marketing-rec/page-type',
        method: 'get',
        params: query
    })
}

//营销素材-选择素材

export function chooseMaterial (query) {
    return request({
        url: '/cp/marketing-rec/choose',
        method: 'get',
        params: query
    })
}

//营销素材-获取选中的素材列表

export function getChooseData (query) {
    return request({
        url: '/cp/marketing-rec/index-type',
        method: 'get',
        params: query
    })
}
// 营销素材-删除选中的素材列表

export function deleteChooseData (obj) {
    return request({
        url: `/cp/marketing-rec/${obj.id}?title=${obj.title}&type=${obj.type}&classification=${obj.classification}`,
        method: 'delete',
    })
}
// 推荐数据自定义排序
export function dragSortRecommended (obj) {
    return request({
        url: '/cp/marketing-rec',
        method: 'post',
        data: obj
    })
}
// 推荐结束

// 热榜开始

//保存列表信息并发布！
export function hotSaveRelease (query) {
    return request({
        url: '/cp/marketing-hot/release',
        method: 'get',
        params: query
    })
}
//得到素材打开次数和发送次数
export function openAndSendTimes (query) {
    return request({
        url: '/cp/marketing-hot/page',
        method: 'get',
        params: query
    })
}
//通过类型获取素材的打开和发送次数
export function typeOpenAndSendTimes (query) {
    return request({
        url: '/cp/marketing-hot/page-type',
        method: 'get',
        params: query
    })
}

// 热榜结束

//文章开始


//营销素材-新增文章 post 编辑文章put

export function newAndEditArticle (obj, method) {
    return request({
        url: '/cp/marketing-article',
        method: method,
        data: obj
    })
}
//发布文章
export function articleRelease (id) {
    return request({
        url: `/cp/marketing-article/release/${id}`,
        method: 'get',
    })
}
//文章标题模糊查询或者分页查询
export function getArticleList (query) {
    return request({
        url: '/cp/marketing-article/index',
        method: 'get',
        params: query
    })
}
//删除文章

export function deleteArticle (id) {
    return request({
        url: `/cp/marketing-article/${id}`,
        method: 'delete',
    })
}
//预览接口
export function articlePreview (obj) {
    return request({
        url: '/cp/marketing-article/preview',
        method: 'post',
        data: obj
    })
}

//文章结束

//链接开始

//新增链接 post 编辑链接 put
export function newAndEditLink (obj, method) {
    return request({
        url: '/cp/marketing-link',
        method: method,
        data: obj
    })
}
//删除链接
export function deleteLink (id) {
    return request({
        url: `/cp/marketing-link/${id}`,
        method: 'delete',
    })
}
//链接标题模糊查询或者分页查询
export function getLinkList (query) {
    return request({
        url: '/cp/marketing-link/index',
        method: 'get',
        params: query
    })
}
//解析链接
export function parseLink (query) {
    return request({
        url: '/cp/medium/parse-link-article',
        method: 'get',
        params: query
    })
}
//发布链接
export function LinkRelease (id) {
    return request({
        url: `/cp/marketing-link/release/${id}`,
        method: 'get',
    })
}
//链接结束

//海报开始

//新增海报 post 编辑链接 put
export function newAndEditPoster (obj, method) {
    return request({
        url: '/cp/marketing-poster',
        method: method,
        data: obj
    })
}
//删除海报
export function deletePoster (id) {
    return request({
        url: `/cp/marketing-poster/${id}`,
        method: 'delete',
    })
}
//海报分页查询
export function getPosterList (query) {
    return request({
        url: '/cp/marketing-poster/index',
        method: 'get',
        params: query
    })
}
//发布海报
export function posterRelease (id) {
    return request({
        url: `/cp/marketing-poster/release/${id}`,
        method: 'get',
    })
}
//海报结束

// PDF开始
//新增pdf post 编辑链接 put
export function newAndEditPdf (obj, method) {
    return request({
        url: '/cp/marketing-pdf',
        method: method,
        data: obj
    })
}
//删除pdf
export function deletePdf (id) {
    return request({
        url: `/cp/marketing-pdf/${id}`,
        method: 'delete',
    })
}
//pdf分页查询
export function getPdfList (query) {
    return request({
        url: '/cp/marketing-pdf/index',
        method: 'get',
        params: query
    })
}
//发布pdf
export function pdfRelease (id) {
    return request({
        url: `/cp/marketing-pdf/release/${id}`,
        method: 'get',
    })
}
// PDF结束

// PPT开始
//新增PPT post 编辑链接 put
export function newAndEditPpt (obj, method) {
    return request({
        url: '/cp/marketing-ppt',
        method: method,
        data: obj
    })
}
//删除PPT
export function deletePpt (id) {
    return request({
        url: `/cp/marketing-ppt/${id}`,
        method: 'delete',
    })
}
//PPT分页查询
export function getPptList (query) {
    return request({
        url: '/cp/marketing-ppt/index',
        method: 'get',
        params: query
    })
}
//发布PPT
export function pptRelease (id) {
    return request({
        url: `/cp/marketing-ppt/release/${id}`,
        method: 'get',
    })
}
// PPT结束

// 文档开始
//新增文档 post 编辑链接 put
export function newAndEditWord (obj, method) {
    return request({
        url: '/cp/marketing-word',
        method: method,
        data: obj
    })
}
//删除文档
export function deleteWord (id) {
    return request({
        url: `/cp/marketing-word/${id}`,
        method: 'delete',
    })
}
//文档分页查询
export function getWordList (query) {
    return request({
        url: '/cp/marketing-word/index',
        method: 'get',
        params: query
    })
}
//发布文档
export function wordRelease (id) {
    return request({
        url: `/cp/marketing-word/release/${id}`,
        method: 'get',
    })
}
// 文档结束

// 表格开始
//新增表格 post 编辑链接 put
export function newAndEditExcel (obj, method) {
    return request({
        url: '/cp/marketing-excel',
        method: method,
        data: obj
    })
}
//删除表格
export function deleteExcel (id) {
    return request({
        url: `/cp/marketing-excel/${id}`,
        method: 'delete',
    })
}
//表格分页查询
export function getExcelList (query) {
    return request({
        url: '/cp/marketing-excel/index',
        method: 'get',
        params: query
    })
}
//发布表格
export function excelRelease (id) {
    return request({
        url: `/cp/marketing-excel/release/${id}`,
        method: 'get',
    })
}
// 表格结束

// 上传
export function sysFileUpload (obj) {
    return request({
        url: '/admin/sys-file/upload',
        method: 'post',
        // responseType: 'blob',
        data: obj,
        headers: {
            Authorization: "Bearer " + store.getters.access_token,
            LdapToken: store.getters.ldap_token,
            "content-type": "multipart/form-data"
        },
    })
}
